#ifndef _QY_THREAD_H
#define _QY_THREAD_H

#include <pthread.h>

namespace qy
{

class Thread
{
public:
    Thread();
	virtual ~Thread();

	bool start();
	bool terminate();
	bool isRunning() { return m_isRunning; }
	void setOverCond(pthread_cond_t *overCond) {  m_overCond = overCond; }

protected:
	virtual int run() = 0;
	virtual void afterRun();

private:
    static void *_start(void *arg);

private:
    pthread_cond_t *m_overCond;

	bool m_isRunning;
	pthread_t m_threadId;
};

}

#endif
